class MerchantProductCategoriesController < ApplicationController
  before_filter :require_merchant_user,:only => [:new,:create,:edit,:update,:destroy]
  include UsersHelper
  # GET /merchant_product_categories
  # GET /merchant_product_categories.json
  def index
    @merchant_product_categories = MerchantProductCategory.all

    respond_to do |format|
      format.html # index.html.erb
      format.json { render json: @merchant_product_categories }
    end
  end

  # GET /merchant_product_categories/1
  # GET /merchant_product_categories/1.json
  def show
    @merchant_product_category = MerchantProductCategory.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.json { render json: @merchant_product_category }
    end
  end

  # GET /merchant_product_categories/new
  # GET /merchant_product_categories/new.json
  def new
    @merchant_product_category = MerchantProductCategory.new

    respond_to do |format|
      format.html # new.html.erb
      format.json { render json: @merchant_product_category }
    end
  end

  # GET /merchant_product_categories/1/edit
  def edit
    @merchant_product_category = MerchantProductCategory.find(params[:id])
  end

  # POST /merchant_product_categories
  # POST /merchant_product_categories.json
  def create
    @merchant_product_category = MerchantProductCategory.new(params[:merchant_product_category])
    @merchant_product_category.merchant = get_current_merchant()
    respond_to do |format|
      if @merchant_product_category.save
        format.html { redirect_to @merchant_product_category, notice: 'Merchant product category was successfully created.' }
        format.json { render json: @merchant_product_category, status: :created, location: @merchant_product_category }
      else
        format.html { render action: "new" }
        format.json { render json: @merchant_product_category.errors, status: :unprocessable_entity }
      end
    end
  end

  # PUT /merchant_product_categories/1
  # PUT /merchant_product_categories/1.json
  def update
    @merchant_product_category = MerchantProductCategory.find(params[:id])

    respond_to do |format|
      if @merchant_product_category.update_attributes(params[:merchant_product_category])
        format.html { redirect_to @merchant_product_category, notice: 'Merchant product category was successfully updated.' }
        format.json { head :no_content }
      else
        format.html { render action: "edit" }
        format.json { render json: @merchant_product_category.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /merchant_product_categories/1
  # DELETE /merchant_product_categories/1.json
  def destroy
    @merchant_product_category = MerchantProductCategory.find(params[:id])
    @merchant_product_category.destroy

    respond_to do |format|
      format.html { redirect_to merchant_product_categories_url }
      format.json { head :no_content }
    end
  end
end
